package com.blog.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.blog.service.ICategoryService;



@Controller
@RequestMapping("/manage/category")
public class CategoryController {
	
	
	@Autowired
	private ICategoryService catService;
	
	// easy UI Tree 
	@RequestMapping("/list")
	@ResponseBody			// 返回  easyui tree 所需要的参数 
	public Object getTreeCategory(@RequestParam(defaultValue="0") int id){
		
		
		return catService.getTreeCategory(id);
		
	}
	
	@RequestMapping("/add_category")
	@ResponseBody			// 返回  easyui tree 所需要的参数 
	public Map add_category(Integer parentId,String name){
		
		Map map = catService.addCategory(parentId,name);
		
		return map;
	}
	
	@RequestMapping("/update_category_name")
	@ResponseBody			// 返回  easyui tree 所需要的参数 
	public Map update_category_name(Integer id,String name){
		
		Map map = catService.updateCategory(id,name);
		
		return map;
	}
	
	@RequestMapping("/delete")
	@ResponseBody			// 返回  easyui tree 所需要的参数 
	public Map delete(Integer parentId, Integer id){
		
		Map map = catService.delete(parentId,id);
	    
		
		
		return map;
	}
}
